<?php
$app_config = require(dirname(__FILE__) . '/../config/boot.php');
require $app_config['QEEPHP_DIR'] . '/library/q.php';
require $app_config['APP_DIR'] . '/myapp.php';
$ret = MyApp::instance($app_config);
$customer = Customer::find()->order('c_no desc')->asArray()->getAll();
$record = array();
foreach ($customer as $c)
{
	$record[] = $c['c_no'].'#'.$c['c_name'];
}
dump(implode('||', $record));
//	/* load the required classes */
//		require_once Q::ini('custom_system/lib_dir')."phpbase/Column.class.php";
//		require_once Q::ini('custom_system/lib_dir')."phpbase/Record.class.php";
//		require_once Q::ini('custom_system/lib_dir')."phpbase/Table.class.php";
//		require_once Q::ini('custom_system/lib_dir')."phpbase/WritableTable.class.php";
//		/* 数据表头*/	
//		$fields = array(
//			array("FID" , DBFFIELD_TYPE_CHAR, 50),
//			array("KHNAME" , DBFFIELD_TYPE_CHAR, 50)
//		);
//		/* create a new table */
//		$tableNew = XBaseWritableTable::create(Q::ini('custom_system/base_url')."dbf/KHData.dbf",$fields);
//		/* insert some data */
//		$customer = Customer::find()->order('c_no desc')->asArray()->getAll();
//		foreach ($customer as $c)
//		{
//			$r =& $tableNew->appendRecord();
//			$r->setObjectByName("FID",$c['c_no']);
//			$r->setObjectByName("KHNAME",$c['c_name']);
//			$tableNew->writeRecord();
//		}
//		/* close the table */
//		$tableNew->close();
		//$filepath = Q::ini('custom_system/base_url')."dbf/KHData.dbf";
//		$url="http://localhost:8080/xf12315/1/public/dbf/KHData.dbf";
		//Helper_BSS_Normal::downfile($filepath);
//		echo "<script language='javascript' type='text/javascript'>";
//		echo "window.location.href='".Q::ini('custom_system/base_url')."dbf/KHData.dbf'";  
//		echo "</script>";  
//		$file_dir = Q::ini('custom_system/base_url')."dbf/";
//		$file_name = "KHData.dbf";
//		$file = fopen($file_dir . $file_name,"r"); // 打开文件
//		// 输入文件标签
//		header("Content-type: application/octet-stream");
//		header("Accept-Ranges: bytes");
//		header("Accept-Length: ".filesize($file_dir . $file_name));
//		header("Content-Disposition: attachment; filename=" . $file_name);
//		// 输出文件内容
//		echo fread($file,filesize($file_dir . $file_name));
//		fclose($file);
		exit;